<?php

class Public_Post_DeleteAction extends BlogPublicBaseAction
{
    /**
     * Process HTTP GET request
     *
     * @param AgaviRequestDataHolder $rd
     * @return string
     */
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        return 'Success';
    }
    
    /**
     * Process HTTP POST request
     *
     * @param AgaviRequestDataHolder $rd
     * @return string
     */
    public function executeWrite(AgaviRequestDataHolder $rd)
    {
		/* @var $model Public_PostsModel */
		$model = $this->getContext()->getModel('Posts', 'Public');
        $post_id = $rd->getParameter('post_id');
        
        $model->deletePost($post_id);
        $this->setAttribute('ok', true);
        AgaviExecutionFilter::clearCache(array('posts_list'));
        
		return 'Success';
    }
    
    /**
	 * Returns the default view if the action does not serve the request
	 * method used.
	 *
	 * @return     mixed <ul>
	 *                     <li>A string containing the view name associated
	 *                     with this action; or</li>
	 *                     <li>An array with two indices: the parent module
	 *                     of the view to be executed and the view to be
	 *                     executed.</li>
	 *                   </ul>
	 */
	public function getDefaultViewName()
	{
		return 'Success';
	}
}

?>